// 用户模型
module.exports = (app) => {
      const mongoose = app.mongoose;
      const Schema = mongoose.Schema;

      const UserSchema = new Schema(
            {
                  __v: { type: Number, select: false },
                  email: { type: String, required: true },
                  password: { type: String, required: true, select: false },
                  username: { type: String, required: true },
                  avatar: {
                        type: String,
                        required: false,
                        default: "/user.png",
                  },
            },
            { timestamps: true }
      );
      // timestamps:true 【会在表中自动添加一个createTime和updateTime两个字段】
      return mongoose.model("User", UserSchema);
};
